{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<table width=\"100%\" summary=\"page for help {utils}\"><tr><td>help {utils}</td><td style=\"text-align: right;\">R Documentation</td></tr></table>\n",
       "\n",
       "<h2>Documentation</h2>\n",
       "\n",
       "<h3>Description</h3>\n",
       "\n",
       "<p><code>help</code> is the primary interface to the help systems.\n",
       "</p>\n",
       "\n",
       "\n",
       "<h3>Usage</h3>\n",
       "\n",
       "<pre>\n",
       "help(topic, package = NULL, lib.loc = NULL,\n",
       "     verbose = getOption(\"verbose\"),\n",
       "     try.all.packages = getOption(\"help.try.all.packages\"),\n",
       "     help_type = getOption(\"help_type\"))\n",
       "</pre>\n",
       "\n",
       "\n",
       "<h3>Arguments</h3>\n",
       "\n",
       "<table summary=\"R argblock\">\n",
       "<tr valign=\"top\"><td><code>topic</code></td>\n",
       "<td>\n",
       "<p>usually, a name or character string specifying the\n",
       "topic for which help is sought.  A character string (enclosed in\n",
       "explicit single or double quotes) is always taken as naming a topic.\n",
       "</p>\n",
       "<p>If the value of <code>topic</code> is a length-one\n",
       "character vector the topic is taken to be the value of the only\n",
       "element.  Otherwise <code>topic</code> must be a name or a reserved\n",
       "word (if syntactically valid) or character string.\n",
       "</p>\n",
       "<p>See &lsquo;Details&rsquo; for what happens if this is omitted.\n",
       "</p>\n",
       "</td></tr>\n",
       "<tr valign=\"top\"><td><code>package</code></td>\n",
       "<td>\n",
       "<p>a name or character vector giving the packages to look\n",
       "into for documentation, or <code>NULL</code>.  By default, all packages \n",
       "whose namespaces are loaded are used.  To avoid a name being deparsed use e.g.\n",
       "<code>(pkg_ref)</code> (see the examples).</p>\n",
       "</td></tr>\n",
       "<tr valign=\"top\"><td><code>lib.loc</code></td>\n",
       "<td>\n",
       "<p>a character vector of directory names of <span style=\"font-family: Courier New, Courier; color: #666666;\"><b>R</b></span> libraries,\n",
       "or <code>NULL</code>.  The default value of <code>NULL</code> corresponds to all\n",
       "libraries currently known.  If the default is used, the loaded\n",
       "packages are searched before the libraries.  This is not used for\n",
       "HTML help (see &lsquo;Details&rsquo;).</p>\n",
       "</td></tr>\n",
       "<tr valign=\"top\"><td><code>verbose</code></td>\n",
       "<td>\n",
       "<p>logical; if <code>TRUE</code>, the file name is reported.</p>\n",
       "</td></tr>\n",
       "<tr valign=\"top\"><td><code>try.all.packages</code></td>\n",
       "<td>\n",
       "<p>logical; see <code>Note</code>.</p>\n",
       "</td></tr>\n",
       "<tr valign=\"top\"><td><code>help_type</code></td>\n",
       "<td>\n",
       "<p>character string: the type of help required.\n",
       "Possible values are <code>\"text\"</code>, <code>\"html\"</code> and <code>\"pdf\"</code>.\n",
       "Case is ignored, and partial matching is allowed.</p>\n",
       "</td></tr>\n",
       "</table>\n",
       "\n",
       "\n",
       "<h3>Details</h3>\n",
       "\n",
       "<p>The following types of help are available:\n",
       "</p>\n",
       "\n",
       "<ul>\n",
       "<li><p> Plain text help\n",
       "</p>\n",
       "</li>\n",
       "<li><p> HTML help pages with hyperlinks to other topics, shown in a\n",
       "browser by <code>browseURL</code>.\n",
       "If for some reason HTML help is unavailable (see\n",
       "<code>startDynamicHelp</code>), plain text help will be used\n",
       "instead.\n",
       "</p>\n",
       "</li>\n",
       "<li><p> For <code>help</code> only, typeset as PDF &ndash;\n",
       "see the section on &lsquo;Offline help&rsquo;.\n",
       "</p>\n",
       "</li></ul>\n",
       "\n",
       "<p>The default for the type of help is selected when <span style=\"font-family: Courier New, Courier; color: #666666;\"><b>R</b></span> is installed &ndash;\n",
       "the &lsquo;factory-fresh&rsquo; default is HTML help.\n",
       "</p>\n",
       "<p>The rendering of text help will use directional quotes in suitable\n",
       "locales (UTF-8 and single-byte Windows locales): sometimes the fonts\n",
       "used do not support these quotes so this can be turned off by setting\n",
       "<code>options(useFancyQuotes = FALSE)</code>.\n",
       "</p>\n",
       "<p><code>topic</code> is not optional: if it is omitted <span style=\"font-family: Courier New, Courier; color: #666666;\"><b>R</b></span> will give\n",
       "</p>\n",
       "\n",
       "<ul>\n",
       "<li><p> If a package is specified, (text or, in interactive use only,\n",
       "HTML) information on the package, including hints/links to suitable\n",
       "help topics.\n",
       "</p>\n",
       "</li>\n",
       "<li><p> If <code>lib.loc</code> only is specified, a (text) list of available\n",
       "packages.\n",
       "</p>\n",
       "</li>\n",
       "<li><p> Help on <code>help</code> itself if none of the first three\n",
       "arguments is specified.\n",
       "</p>\n",
       "</li></ul>\n",
       "\n",
       "<p>Some topics need to be quoted (by backticks) or given as a\n",
       "character string.  These include those which cannot syntactically\n",
       "appear on their own such as unary and binary operators,\n",
       "<code>function</code> and control-flow reserved words (including\n",
       "<code>if</code>, <code>else</code> <code>for</code>, <code>in</code>, <code>repeat</code>,\n",
       "<code>while</code>, <code>break</code> and <code>next</code>).  The other <code>reserved</code>\n",
       "words can be used as if they were names, for example <code>TRUE</code>,\n",
       "<code>NA</code> and <code>Inf</code>.\n",
       "</p>\n",
       "<p>If multiple help files matching <code>topic</code> are found, in interactive\n",
       "use a menu is presented for the user to choose one: in batch use the\n",
       "first on the search path is used.  (For HTML help the menu will be an\n",
       "HTML page, otherwise a graphical menu if possible if\n",
       "<code>getOption(\"menu.graphics\")</code> is true, the default.)\n",
       "</p>\n",
       "<p>Note that HTML help does not make use of <code>lib.loc</code>: it will\n",
       "always look first in the loaded packages and then along\n",
       "<code>.libPaths()</code>.\n",
       "</p>\n",
       "\n",
       "\n",
       "<h3>Offline help</h3>\n",
       "\n",
       "<p>Typeset documentation is produced by running the LaTeX version of the\n",
       "help page through <code>pdflatex</code>: this will produce a PDF file.\n",
       "</p>\n",
       "<p>The appearance of the output can be customized through a file\n",
       "&lsquo;<span class=\"file\">Rhelp.cfg</span>&rsquo; somewhere in your LaTeX search path: this will be\n",
       "input as a LaTeX style file after <code>Rd.sty</code>.  Some\n",
       "environment variables are consulted, notably <span class=\"env\">R_PAPERSIZE</span>\n",
       "(<em>via</em> <code>getOption(\"papersize\")</code>) and <span class=\"env\">R_RD4PDF</span> (see\n",
       "&lsquo;Making manuals&rsquo; in the &lsquo;R Installation and\n",
       "Administration Manual&rsquo;).\n",
       "</p>\n",
       "<p>If there is a function <code>offline_help_helper</code> in the workspace or\n",
       "further down the search path it is used to do the typesetting,\n",
       "otherwise the function of that name in the <code>utils</code> namespace (to\n",
       "which the first paragraph applies).  It should accept at least two\n",
       "arguments, the name of the LaTeX file to be typeset and the type\n",
       "(which is nowadays ignored).  It accepts a third argument,\n",
       "<code>texinputs</code>, which will give the graphics path when the help\n",
       "document contains figures, and will otherwise not be supplied.\n",
       "</p>\n",
       "\n",
       "\n",
       "<h3>Note</h3>\n",
       "\n",
       "<p>Unless <code>lib.loc</code> is specified explicitly, the loaded packages are\n",
       "searched before those in the specified libraries.  This ensures that\n",
       "if a library is loaded from a library not in the known library trees,\n",
       "then the help from the loaded library is used.  If <code>lib.loc</code> is\n",
       "specified explicitly, the loaded packages are <em>not</em> searched.\n",
       "</p>\n",
       "<p>If this search fails and argument <code>try.all.packages</code> is\n",
       "<code>TRUE</code> and neither <code>packages</code> nor <code>lib.loc</code> is\n",
       "specified, then all the packages in the known library trees are\n",
       "searched for help on <code>topic</code> and a list of (any) packages where\n",
       "help may be found is displayed (with hyperlinks for <code>help_type =\n",
       "  \"html\"</code>).  <strong>NB:</strong> searching all packages can be slow, especially\n",
       "the first time (caching of files by the OS can expedite subsequent\n",
       "searches dramatically).\n",
       "</p>\n",
       "\n",
       "\n",
       "<h3>References</h3>\n",
       "\n",
       "<p>Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\n",
       "<em>The New S Language</em>.\n",
       "Wadsworth &amp; Brooks/Cole.\n",
       "</p>\n",
       "\n",
       "\n",
       "<h3>See Also</h3>\n",
       "\n",
       "<p><code>?</code> for shortcuts to help topics.\n",
       "</p>\n",
       "<p><code>help.search()</code> or <code>??</code> for finding help pages\n",
       "on a vague topic;\n",
       "<code>help.start()</code> which opens the HTML version of the <span style=\"font-family: Courier New, Courier; color: #666666;\"><b>R</b></span>\n",
       "help pages;\n",
       "<code>library()</code> for listing available packages and the\n",
       "help objects they contain;\n",
       "<code>data()</code> for listing available data sets;\n",
       "<code>methods()</code>.\n",
       "</p>\n",
       "<p>Use <code>prompt()</code> to get a prototype for writing <code>help</code>\n",
       "pages of your own package.\n",
       "</p>\n",
       "\n",
       "\n",
       "<h3>Examples</h3>\n",
       "\n",
       "<pre>\n",
       "help()\n",
       "help(help)              # the same\n",
       "\n",
       "help(lapply)\n",
       "\n",
       "help(\"for\")             # or ?\"for\", but quotes/backticks are needed\n",
       "\n",
       "try({# requires working TeX installation:\n",
       " help(dgamma, help_type = \"pdf\")\n",
       " ## -&gt; nicely formatted pdf -- including math formula -- for help(dgamma):\n",
       " system2(getOption(\"pdfviewer\"), \"dgamma.pdf\", wait = FALSE)\n",
       "})\n",
       "\n",
       "help(package = \"splines\") # get help even when package is not loaded\n",
       "\n",
       "topi &lt;- \"women\"\n",
       "help(topi)\n",
       "\n",
       "try(help(\"bs\", try.all.packages = FALSE)) # reports not found (an error)\n",
       "help(\"bs\", try.all.packages = TRUE)       # reports can be found\n",
       "                                          # in package 'splines'\n",
       "\n",
       "## For programmatic use:\n",
       "topic &lt;- \"family\"; pkg_ref &lt;- \"stats\"\n",
       "help((topic), (pkg_ref))\n",
       "</pre>\n",
       "\n",
       "<hr /><div style=\"text-align: center;\">[Package <em>utils</em> version 3.5.1 ]</div>"
      ],
      "text/latex": [
       "\\inputencoding{utf8}\n",
       "\\HeaderA{help}{Documentation}{help}\n",
       "\\keyword{documentation}{help}\n",
       "%\n",
       "\\begin{Description}\\relax\n",
       "\\code{help} is the primary interface to the help systems.\n",
       "\\end{Description}\n",
       "%\n",
       "\\begin{Usage}\n",
       "\\begin{verbatim}\n",
       "help(topic, package = NULL, lib.loc = NULL,\n",
       "     verbose = getOption(\"verbose\"),\n",
       "     try.all.packages = getOption(\"help.try.all.packages\"),\n",
       "     help_type = getOption(\"help_type\"))\n",
       "\\end{verbatim}\n",
       "\\end{Usage}\n",
       "%\n",
       "\\begin{Arguments}\n",
       "\\begin{ldescription}\n",
       "\\item[\\code{topic}] usually, a \\LinkA{name}{name} or character string specifying the\n",
       "topic for which help is sought.  A character string (enclosed in\n",
       "explicit single or double quotes) is always taken as naming a topic.\n",
       "\n",
       "If the value of \\code{topic} is a length-one\n",
       "character vector the topic is taken to be the value of the only\n",
       "element.  Otherwise \\code{topic} must be a name or a \\LinkA{reserved}{reserved}\n",
       "word (if syntactically valid) or character string.\n",
       "\n",
       "See `Details' for what happens if this is omitted.\n",
       "\n",
       "\\item[\\code{package}] a name or character vector giving the packages to look\n",
       "into for documentation, or \\code{NULL}.  By default, all packages \n",
       "whose namespaces are loaded are used.  To avoid a name being deparsed use e.g.\n",
       "\\code{(pkg\\_ref)} (see the examples).\n",
       "\\item[\\code{lib.loc}] a character vector of directory names of \\R{} libraries,\n",
       "or \\code{NULL}.  The default value of \\code{NULL} corresponds to all\n",
       "libraries currently known.  If the default is used, the loaded\n",
       "packages are searched before the libraries.  This is not used for\n",
       "HTML help (see `Details').\n",
       "\\item[\\code{verbose}] logical; if \\code{TRUE}, the file name is reported.\n",
       "\\item[\\code{try.all.packages}] logical; see \\code{Note}.\n",
       "\\item[\\code{help\\_type}] character string: the type of help required.\n",
       "Possible values are \\code{\"text\"}, \\code{\"html\"} and \\code{\"pdf\"}.\n",
       "Case is ignored, and partial matching is allowed.\n",
       "\\end{ldescription}\n",
       "\\end{Arguments}\n",
       "%\n",
       "\\begin{Details}\\relax\n",
       "The following types of help are available:\n",
       "\\begin{itemize}\n",
       "\n",
       "\\item Plain text help\n",
       "\\item HTML help pages with hyperlinks to other topics, shown in a\n",
       "browser by \\code{\\LinkA{browseURL}{browseURL}}.\n",
       "If for some reason HTML help is unavailable (see\n",
       "\\code{\\LinkA{startDynamicHelp}{startDynamicHelp}}), plain text help will be used\n",
       "instead.\n",
       "\\item For \\code{help} only, typeset as PDF --\n",
       "see the section on `Offline help'.\n",
       "\n",
       "\\end{itemize}\n",
       "\n",
       "The default for the type of help is selected when \\R{} is installed --\n",
       "the `factory-fresh' default is HTML help.\n",
       "\n",
       "The rendering of text help will use directional quotes in suitable\n",
       "locales (UTF-8 and single-byte Windows locales): sometimes the fonts\n",
       "used do not support these quotes so this can be turned off by setting\n",
       "\\code{\\LinkA{options}{options}(useFancyQuotes = FALSE)}.\n",
       "\n",
       "\\code{topic} is not optional: if it is omitted \\R{} will give\n",
       "\\begin{itemize}\n",
       "\n",
       "\\item If a package is specified, (text or, in interactive use only,\n",
       "HTML) information on the package, including hints/links to suitable\n",
       "help topics.\n",
       "\\item If \\code{lib.loc} only is specified, a (text) list of available\n",
       "packages.\n",
       "\\item Help on \\code{help} itself if none of the first three\n",
       "arguments is specified.\n",
       "\n",
       "\\end{itemize}\n",
       "\n",
       "\n",
       "Some topics need to be quoted (by \\LinkA{backtick}{backtick}s) or given as a\n",
       "character string.  These include those which cannot syntactically\n",
       "appear on their own such as unary and binary operators,\n",
       "\\code{function} and control-flow \\LinkA{reserved}{reserved} words (including\n",
       "\\code{if}, \\code{else} \\code{for}, \\code{in}, \\code{repeat},\n",
       "\\code{while}, \\code{break} and \\code{next}).  The other \\code{reserved}\n",
       "words can be used as if they were names, for example \\code{TRUE},\n",
       "\\code{NA} and \\code{Inf}.\n",
       "\n",
       "If multiple help files matching \\code{topic} are found, in interactive\n",
       "use a menu is presented for the user to choose one: in batch use the\n",
       "first on the search path is used.  (For HTML help the menu will be an\n",
       "HTML page, otherwise a graphical menu if possible if\n",
       "\\code{\\LinkA{getOption}{getOption}(\"menu.graphics\")} is true, the default.)\n",
       "\n",
       "Note that HTML help does not make use of \\code{lib.loc}: it will\n",
       "always look first in the loaded packages and then along\n",
       "\\code{.libPaths()}.\n",
       "\\end{Details}\n",
       "%\n",
       "\\begin{Section}{Offline help}\n",
       "Typeset documentation is produced by running the LaTeX version of the\n",
       "help page through \\command{pdflatex}: this will produce a PDF file.\n",
       "\n",
       "The appearance of the output can be customized through a file\n",
       "\\file{Rhelp.cfg} somewhere in your LaTeX search path: this will be\n",
       "input as a LaTeX style file after \\code{Rd.sty}.  Some\n",
       "\\LinkA{environment variables}{environment variables} are consulted, notably \\env{R\\_PAPERSIZE}\n",
       "(\\emph{via} \\code{getOption(\"papersize\")}) and \\env{R\\_RD4PDF} (see\n",
       "`Making manuals' in the `R Installation and\n",
       "Administration Manual').\n",
       "\n",
       "If there is a function \\code{offline\\_help\\_helper} in the workspace or\n",
       "further down the search path it is used to do the typesetting,\n",
       "otherwise the function of that name in the \\code{utils} namespace (to\n",
       "which the first paragraph applies).  It should accept at least two\n",
       "arguments, the name of the LaTeX file to be typeset and the type\n",
       "(which is nowadays ignored).  It accepts a third argument,\n",
       "\\code{texinputs}, which will give the graphics path when the help\n",
       "document contains figures, and will otherwise not be supplied.\n",
       "\\end{Section}\n",
       "%\n",
       "\\begin{Note}\\relax\n",
       "Unless \\code{lib.loc} is specified explicitly, the loaded packages are\n",
       "searched before those in the specified libraries.  This ensures that\n",
       "if a library is loaded from a library not in the known library trees,\n",
       "then the help from the loaded library is used.  If \\code{lib.loc} is\n",
       "specified explicitly, the loaded packages are \\emph{not} searched.\n",
       "\n",
       "If this search fails and argument \\code{try.all.packages} is\n",
       "\\code{TRUE} and neither \\code{packages} nor \\code{lib.loc} is\n",
       "specified, then all the packages in the known library trees are\n",
       "searched for help on \\code{topic} and a list of (any) packages where\n",
       "help may be found is displayed (with hyperlinks for \\code{help\\_type =\n",
       "  \"html\"}).  \\strong{NB:} searching all packages can be slow, especially\n",
       "the first time (caching of files by the OS can expedite subsequent\n",
       "searches dramatically).\n",
       "\\end{Note}\n",
       "%\n",
       "\\begin{References}\\relax\n",
       "Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)\n",
       "\\emph{The New S Language}.\n",
       "Wadsworth \\& Brooks/Cole.\n",
       "\\end{References}\n",
       "%\n",
       "\\begin{SeeAlso}\\relax\n",
       "\\code{\\LinkA{?}{Question}} for shortcuts to help topics.\n",
       "\n",
       "\\code{\\LinkA{help.search}{help.search}()} or \\code{\\LinkA{??}{??}} for finding help pages\n",
       "on a vague topic;\n",
       "\\code{\\LinkA{help.start}{help.start}()} which opens the HTML version of the \\R{}\n",
       "help pages;\n",
       "\\code{\\LinkA{library}{library}()} for listing available packages and the\n",
       "help objects they contain;\n",
       "\\code{\\LinkA{data}{data}()} for listing available data sets;\n",
       "\\code{\\LinkA{methods}{methods}()}.\n",
       "\n",
       "Use \\code{\\LinkA{prompt}{prompt}()} to get a prototype for writing \\code{help}\n",
       "pages of your own package.\n",
       "\\end{SeeAlso}\n",
       "%\n",
       "\\begin{Examples}\n",
       "\\begin{ExampleCode}\n",
       "help()\n",
       "help(help)              # the same\n",
       "\n",
       "help(lapply)\n",
       "\n",
       "help(\"for\")             # or ?\"for\", but quotes/backticks are needed\n",
       "\n",
       "try({# requires working TeX installation:\n",
       " help(dgamma, help_type = \"pdf\")\n",
       " ## -> nicely formatted pdf -- including math formula -- for help(dgamma):\n",
       " system2(getOption(\"pdfviewer\"), \"dgamma.pdf\", wait = FALSE)\n",
       "})\n",
       "\n",
       "help(package = \"splines\") # get help even when package is not loaded\n",
       "\n",
       "topi <- \"women\"\n",
       "help(topi)\n",
       "\n",
       "try(help(\"bs\", try.all.packages = FALSE)) # reports not found (an error)\n",
       "help(\"bs\", try.all.packages = TRUE)       # reports can be found\n",
       "                                          # in package 'splines'\n",
       "\n",
       "## For programmatic use:\n",
       "topic <- \"family\"; pkg_ref <- \"stats\"\n",
       "help((topic), (pkg_ref))\n",
       "\\end{ExampleCode}\n",
       "\\end{Examples}"
      ],
      "text/plain": [
       "help                   package:utils                   R Documentation\n",
       "\n",
       "_\bD_\bo_\bc_\bu_\bm_\be_\bn_\bt_\ba_\bt_\bi_\bo_\bn\n",
       "\n",
       "_\bD_\be_\bs_\bc_\br_\bi_\bp_\bt_\bi_\bo_\bn:\n",
       "\n",
       "     'help' is the primary interface to the help systems.\n",
       "\n",
       "_\bU_\bs_\ba_\bg_\be:\n",
       "\n",
       "     help(topic, package = NULL, lib.loc = NULL,\n",
       "          verbose = getOption(\"verbose\"),\n",
       "          try.all.packages = getOption(\"help.try.all.packages\"),\n",
       "          help_type = getOption(\"help_type\"))\n",
       "     \n",
       "_\bA_\br_\bg_\bu_\bm_\be_\bn_\bt_\bs:\n",
       "\n",
       "   topic: usually, a name or character string specifying the topic for\n",
       "          which help is sought.  A character string (enclosed in\n",
       "          explicit single or double quotes) is always taken as naming a\n",
       "          topic.\n",
       "\n",
       "          If the value of 'topic' is a length-one character vector the\n",
       "          topic is taken to be the value of the only element.\n",
       "          Otherwise 'topic' must be a name or a reserved word (if\n",
       "          syntactically valid) or character string.\n",
       "\n",
       "          See 'Details' for what happens if this is omitted.\n",
       "\n",
       " package: a name or character vector giving the packages to look into\n",
       "          for documentation, or 'NULL'.  By default, all packages whose\n",
       "          namespaces are loaded are used.  To avoid a name being\n",
       "          deparsed use e.g.  '(pkg_ref)' (see the examples).\n",
       "\n",
       " lib.loc: a character vector of directory names of R libraries, or\n",
       "          'NULL'.  The default value of 'NULL' corresponds to all\n",
       "          libraries currently known.  If the default is used, the\n",
       "          loaded packages are searched before the libraries.  This is\n",
       "          not used for HTML help (see 'Details').\n",
       "\n",
       " verbose: logical; if 'TRUE', the file name is reported.\n",
       "\n",
       "try.all.packages: logical; see 'Note'.\n",
       "\n",
       "help_type: character string: the type of help required.  Possible\n",
       "          values are '\"text\"', '\"html\"' and '\"pdf\"'.  Case is ignored,\n",
       "          and partial matching is allowed.\n",
       "\n",
       "_\bD_\be_\bt_\ba_\bi_\bl_\bs:\n",
       "\n",
       "     The following types of help are available:\n",
       "\n",
       "        * Plain text help\n",
       "\n",
       "        * HTML help pages with hyperlinks to other topics, shown in a\n",
       "          browser by 'browseURL'.  If for some reason HTML help is\n",
       "          unavailable (see 'startDynamicHelp'), plain text help will be\n",
       "          used instead.\n",
       "\n",
       "        * For 'help' only, typeset as PDF - see the section on 'Offline\n",
       "          help'.\n",
       "\n",
       "     The default for the type of help is selected when R is installed -\n",
       "     the 'factory-fresh' default is HTML help.\n",
       "\n",
       "     The rendering of text help will use directional quotes in suitable\n",
       "     locales (UTF-8 and single-byte Windows locales): sometimes the\n",
       "     fonts used do not support these quotes so this can be turned off\n",
       "     by setting 'options(useFancyQuotes = FALSE)'.\n",
       "\n",
       "     'topic' is not optional: if it is omitted R will give\n",
       "\n",
       "        * If a package is specified, (text or, in interactive use only,\n",
       "          HTML) information on the package, including hints/links to\n",
       "          suitable help topics.\n",
       "\n",
       "        * If 'lib.loc' only is specified, a (text) list of available\n",
       "          packages.\n",
       "\n",
       "        * Help on 'help' itself if none of the first three arguments is\n",
       "          specified.\n",
       "\n",
       "     Some topics need to be quoted (by backticks) or given as a\n",
       "     character string.  These include those which cannot syntactically\n",
       "     appear on their own such as unary and binary operators, 'function'\n",
       "     and control-flow reserved words (including 'if', 'else' 'for',\n",
       "     'in', 'repeat', 'while', 'break' and 'next').  The other\n",
       "     'reserved' words can be used as if they were names, for example\n",
       "     'TRUE', 'NA' and 'Inf'.\n",
       "\n",
       "     If multiple help files matching 'topic' are found, in interactive\n",
       "     use a menu is presented for the user to choose one: in batch use\n",
       "     the first on the search path is used.  (For HTML help the menu\n",
       "     will be an HTML page, otherwise a graphical menu if possible if\n",
       "     'getOption(\"menu.graphics\")' is true, the default.)\n",
       "\n",
       "     Note that HTML help does not make use of 'lib.loc': it will always\n",
       "     look first in the loaded packages and then along '.libPaths()'.\n",
       "\n",
       "_\bO_\bf_\bf_\bl_\bi_\bn_\be _\bh_\be_\bl_\bp:\n",
       "\n",
       "     Typeset documentation is produced by running the LaTeX version of\n",
       "     the help page through 'pdflatex': this will produce a PDF file.\n",
       "\n",
       "     The appearance of the output can be customized through a file\n",
       "     'Rhelp.cfg' somewhere in your LaTeX search path: this will be\n",
       "     input as a LaTeX style file after 'Rd.sty'.  Some environment\n",
       "     variables are consulted, notably 'R_PAPERSIZE' (_via_\n",
       "     'getOption(\"papersize\")') and 'R_RD4PDF' (see 'Making manuals' in\n",
       "     the 'R Installation and Administration Manual').\n",
       "\n",
       "     If there is a function 'offline_help_helper' in the workspace or\n",
       "     further down the search path it is used to do the typesetting,\n",
       "     otherwise the function of that name in the 'utils' namespace (to\n",
       "     which the first paragraph applies).  It should accept at least two\n",
       "     arguments, the name of the LaTeX file to be typeset and the type\n",
       "     (which is nowadays ignored).  It accepts a third argument,\n",
       "     'texinputs', which will give the graphics path when the help\n",
       "     document contains figures, and will otherwise not be supplied.\n",
       "\n",
       "_\bN_\bo_\bt_\be:\n",
       "\n",
       "     Unless 'lib.loc' is specified explicitly, the loaded packages are\n",
       "     searched before those in the specified libraries.  This ensures\n",
       "     that if a library is loaded from a library not in the known\n",
       "     library trees, then the help from the loaded library is used.  If\n",
       "     'lib.loc' is specified explicitly, the loaded packages are _not_\n",
       "     searched.\n",
       "\n",
       "     If this search fails and argument 'try.all.packages' is 'TRUE' and\n",
       "     neither 'packages' nor 'lib.loc' is specified, then all the\n",
       "     packages in the known library trees are searched for help on\n",
       "     'topic' and a list of (any) packages where help may be found is\n",
       "     displayed (with hyperlinks for 'help_type = \"html\"').  *NB:*\n",
       "     searching all packages can be slow, especially the first time\n",
       "     (caching of files by the OS can expedite subsequent searches\n",
       "     dramatically).\n",
       "\n",
       "_\bR_\be_\bf_\be_\br_\be_\bn_\bc_\be_\bs:\n",
       "\n",
       "     Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) _The New S\n",
       "     Language_.  Wadsworth & Brooks/Cole.\n",
       "\n",
       "_\bS_\be_\be _\bA_\bl_\bs_\bo:\n",
       "\n",
       "     '?' for shortcuts to help topics.\n",
       "\n",
       "     'help.search()' or '??' for finding help pages on a vague topic;\n",
       "     'help.start()' which opens the HTML version of the R help pages;\n",
       "     'library()' for listing available packages and the help objects\n",
       "     they contain; 'data()' for listing available data sets;\n",
       "     'methods()'.\n",
       "\n",
       "     Use 'prompt()' to get a prototype for writing 'help' pages of your\n",
       "     own package.\n",
       "\n",
       "_\bE_\bx_\ba_\bm_\bp_\bl_\be_\bs:\n",
       "\n",
       "     help()\n",
       "     help(help)              # the same\n",
       "     \n",
       "     help(lapply)\n",
       "     \n",
       "     help(\"for\")             # or ?\"for\", but quotes/backticks are needed\n",
       "     \n",
       "     try({# requires working TeX installation:\n",
       "      help(dgamma, help_type = \"pdf\")\n",
       "      ## -> nicely formatted pdf -- including math formula -- for help(dgamma):\n",
       "      system2(getOption(\"pdfviewer\"), \"dgamma.pdf\", wait = FALSE)\n",
       "     })\n",
       "     \n",
       "     help(package = \"splines\") # get help even when package is not loaded\n",
       "     \n",
       "     topi <- \"women\"\n",
       "     help(topi)\n",
       "     \n",
       "     try(help(\"bs\", try.all.packages = FALSE)) # reports not found (an error)\n",
       "     help(\"bs\", try.all.packages = TRUE)       # reports can be found\n",
       "                                               # in package 'splines'\n",
       "     \n",
       "     ## For programmatic use:\n",
       "     topic <- \"family\"; pkg_ref <- \"stats\"\n",
       "     help((topic), (pkg_ref))\n",
       "     "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "help()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "ename": "ERROR",
     "evalue": "Error in library(car): there is no package called 'car'\n",
     "execution_count": 2,
     "output_type": "error",
     "traceback": [
      "Error in library(car): there is no package called 'car'\nTraceback:\n",
      "1. library(car)",
      "2. stop(txt, domain = NA)"
     ]
    }
   ],
   "source": [
    "library(car)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {},
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": [
       "R packages available\n",
       "\n",
       "Packages in library 'C:/Users/ljt/Anaconda3/envs/R3.4/Lib/R/library':\n",
       "\n",
       "abind                   Combine Multidimensional Arrays\n",
       "assertthat              Easy Pre and Post Assertions\n",
       "backports               Reimplementations of Functions Introduced Since\n",
       "                        R-3.0.0\n",
       "base                    The R Base Package\n",
       "base64enc               Tools for base64 encoding\n",
       "BH                      Boost C++ Header Files\n",
       "bindr                   Parametrized Active Bindings\n",
       "bindrcpp                An 'Rcpp' Interface to Active Bindings\n",
       "boot                    Bootstrap Functions (Originally by Angelo Canty\n",
       "                        for S)\n",
       "broom                   Convert Statistical Analysis Objects into Tidy\n",
       "                        Tibbles\n",
       "callr                   Call R from R\n",
       "caret                   Classification and Regression Training\n",
       "cellranger              Translate Spreadsheet Cell Ranges to Rows and\n",
       "                        Columns\n",
       "class                   Functions for Classification\n",
       "cli                     Helpers for Developing Command Line Interfaces\n",
       "clipr                   Read and Write from the System Clipboard\n",
       "cluster                 \"Finding Groups in Data\": Cluster Analysis\n",
       "                        Extended Rousseeuw et al.\n",
       "codetools               Code Analysis Tools for R\n",
       "colorspace              Color Space Manipulation\n",
       "compiler                The R Compiler Package\n",
       "crayon                  Colored Terminal Output\n",
       "curl                    A Modern and Flexible Web Client for R\n",
       "CVST                    Fast Cross-Validation via Sequential Testing\n",
       "data.table              Extension of `data.frame`\n",
       "datasets                The R Datasets Package\n",
       "DBI                     R Database Interface\n",
       "dbplyr                  A 'dplyr' Back End for Databases\n",
       "ddalpha                 Depth-Based Classification and Calculation of\n",
       "                        Data Depth\n",
       "DEoptimR                Differential Evolution Optimization in Pure R\n",
       "dichromat               Color Schemes for Dichromats\n",
       "digest                  Create Compact Hash Digests of R Objects\n",
       "dimRed                  A Framework for Dimensionality Reduction\n",
       "dplyr                   A Grammar of Data Manipulation\n",
       "DRR                     Dimensionality Reduction via Regression\n",
       "evaluate                Parsing and Evaluation Tools that Provide More\n",
       "                        Details than the Default\n",
       "fansi                   ANSI Control Sequence Aware String Functions\n",
       "forcats                 Tools for Working with Categorical Variables\n",
       "                        (Factors)\n",
       "foreach                 Provides Foreach Looping Construct for R\n",
       "forecast                Forecasting Functions for Time Series and\n",
       "                        Linear Models\n",
       "foreign                 Read Data Stored by 'Minitab', 'S', 'SAS',\n",
       "                        'SPSS', 'Stata', 'Systat', 'Weka', 'dBase', ...\n",
       "formatR                 Format R Code Automatically\n",
       "fracdiff                Fractionally differenced ARIMA aka\n",
       "                        ARFIMA(p,d,q) models\n",
       "geometry                Mesh Generation and Surface Tesselation\n",
       "ggplot2                 Create Elegant Data Visualisations Using the\n",
       "                        Grammar of Graphics\n",
       "glmnet                  Lasso and Elastic-Net Regularized Generalized\n",
       "                        Linear Models\n",
       "glue                    Interpreted String Literals\n",
       "gower                   Gower's Distance\n",
       "graphics                The R Graphics Package\n",
       "grDevices               The R Graphics Devices and Support for Colours\n",
       "                        and Fonts\n",
       "grid                    The Grid Graphics Package\n",
       "gtable                  Arrange 'Grobs' in Tables\n",
       "haven                   Import and Export 'SPSS', 'Stata' and 'SAS'\n",
       "                        Files\n",
       "hexbin                  Hexagonal Binning Routines\n",
       "highr                   Syntax Highlighting for R Source Code\n",
       "hms                     Pretty Time of Day\n",
       "htmltools               Tools for HTML\n",
       "htmlwidgets             HTML Widgets for R\n",
       "httpuv                  HTTP and WebSocket Server Library\n",
       "httr                    Tools for Working with URLs and HTTP\n",
       "ipred                   Improved Predictors\n",
       "IRdisplay               'Jupyter' Display Machinery\n",
       "IRkernel                Native R Kernel for the 'Jupyter Notebook'\n",
       "iterators               Provides Iterator Construct for R\n",
       "jsonlite                A Robust, High Performance JSON Parser and\n",
       "                        Generator for R\n",
       "kernlab                 Kernel-Based Machine Learning Lab\n",
       "KernSmooth              Functions for Kernel Smoothing Supporting Wand\n",
       "                        & Jones (1995)\n",
       "knitr                   A General-Purpose Package for Dynamic Report\n",
       "                        Generation in R\n",
       "labeling                Axis Labeling\n",
       "later                   Utilities for Delaying Function Execution\n",
       "lattice                 Trellis Graphics for R\n",
       "lava                    Latent Variable Models\n",
       "lazyeval                Lazy (Non-Standard) Evaluation\n",
       "lmtest                  Testing Linear Regression Models\n",
       "lubridate               Make Dealing with Dates a Little Easier\n",
       "magic                   Create and Investigate Magic Squares\n",
       "magrittr                A Forward-Pipe Operator for R\n",
       "maps                    Draw Geographical Maps\n",
       "markdown                'Markdown' Rendering for R\n",
       "MASS                    Support Functions and Datasets for Venables and\n",
       "                        Ripley's MASS\n",
       "Matrix                  Sparse and Dense Matrix Classes and Methods\n",
       "methods                 Formal Methods and Classes\n",
       "mgcv                    Mixed GAM Computation Vehicle with Automatic\n",
       "                        Smoothness Estimation\n",
       "mime                    Map Filenames to MIME Types\n",
       "ModelMetrics            Rapid Calculation of Model Metrics\n",
       "modelr                  Modelling Functions that Work with the Pipe\n",
       "munsell                 Utilities for Using Munsell Colours\n",
       "nlme                    Linear and Nonlinear Mixed Effects Models\n",
       "nnet                    Feed-Forward Neural Networks and Multinomial\n",
       "                        Log-Linear Models\n",
       "numDeriv                Accurate Numerical Derivatives\n",
       "openssl                 Toolkit for Encryption, Signatures and\n",
       "                        Certificates Based on OpenSSL\n",
       "parallel                Support for Parallel computation in R\n",
       "pbdZMQ                  Programming with Big Data -- Interface to\n",
       "                        'ZeroMQ'\n",
       "pillar                  Coloured Formatting for Columns\n",
       "pkgconfig               Private Configuration for 'R' Packages\n",
       "plogr                   The 'plog' C++ Logging Library\n",
       "pls                     Partial Least Squares and Principal Component\n",
       "                        Regression\n",
       "plyr                    Tools for Splitting, Applying and Combining\n",
       "                        Data\n",
       "praise                  Praise Users\n",
       "processx                Execute and Control System Processes\n",
       "prodlim                 Product-Limit Estimation for Censored Event\n",
       "                        History Analysis\n",
       "promises                Abstractions for Promise-Based Asynchronous\n",
       "                        Programming\n",
       "purrr                   Functional Programming Tools\n",
       "quadprog                Functions to solve Quadratic Programming\n",
       "                        Problems.\n",
       "quantmod                Quantitative Financial Modelling Framework\n",
       "R6                      Classes with Reference Semantics\n",
       "randomForest            Breiman and Cutler's Random Forests for\n",
       "                        Classification and Regression\n",
       "rbokeh                  R Interface for Bokeh\n",
       "RColorBrewer            ColorBrewer Palettes\n",
       "Rcpp                    Seamless R and C++ Integration\n",
       "RcppArmadillo           'Rcpp' Integration for the 'Armadillo'\n",
       "                        Templated Linear Algebra Library\n",
       "RcppRoll                Efficient Rolling / Windowed Operations\n",
       "readr                   Read Rectangular Text Data\n",
       "readxl                  Read Excel Files\n",
       "recipes                 Preprocessing Tools to Create Design Matrices\n",
       "rematch                 Match Regular Expressions with a Nicer 'API'\n",
       "repr                    Serializable Representations\n",
       "reprex                  Prepare Reproducible Example Code via the\n",
       "                        Clipboard\n",
       "reshape2                Flexibly Reshape Data: A Reboot of the Reshape\n",
       "                        Package\n",
       "rlang                   Functions for Base Types and Core R and\n",
       "                        'Tidyverse' Features\n",
       "rmarkdown               Dynamic Documents for R\n",
       "robustbase              Basic Robust Statistics\n",
       "rpart                   Recursive Partitioning and Regression Trees\n",
       "rprojroot               Finding Files in Project Subdirectories\n",
       "rstudioapi              Safely Access the RStudio API\n",
       "rvest                   Easily Harvest (Scrape) Web Pages\n",
       "scales                  Scale Functions for Visualization\n",
       "selectr                 Translate CSS Selectors to XPath Expressions\n",
       "sfsmisc                 Utilities from 'Seminar fuer Statistik' ETH\n",
       "                        Zurich\n",
       "shiny                   Web Application Framework for R\n",
       "sourcetools             Tools for Reading, Tokenizing and Parsing R\n",
       "                        Code\n",
       "spatial                 Functions for Kriging and Point Pattern\n",
       "                        Analysis\n",
       "splines                 Regression Spline Functions and Classes\n",
       "SQUAREM                 Squared Extrapolation Methods for Accelerating\n",
       "                        EM-Like Monotone Algorithms\n",
       "stats                   The R Stats Package\n",
       "stats4                  Statistical Functions using S4 Classes\n",
       "stringi                 Character String Processing Facilities\n",
       "stringr                 Simple, Consistent Wrappers for Common String\n",
       "                        Operations\n",
       "survival                Survival Analysis\n",
       "tcltk                   Tcl/Tk Interface\n",
       "testthat                Unit Testing for R\n",
       "tibble                  Simple Data Frames\n",
       "tidyr                   Easily Tidy Data with 'spread()' and 'gather()'\n",
       "                        Functions\n",
       "tidyselect              Select from a Set of Strings\n",
       "tidyverse               Easily Install and Load the 'Tidyverse'\n",
       "timeDate                Rmetrics - Chronological and Calendar Objects\n",
       "tinytex                 Helper Functions to Install and Maintain 'TeX\n",
       "                        Live', and Compile 'LaTeX' Documents\n",
       "tools                   Tools for Package Development\n",
       "translations            The R Translations Package\n",
       "tseries                 Time Series Analysis and Computational Finance\n",
       "TTR                     Technical Trading Rules\n",
       "urca                    Unit Root and Cointegration Tests for Time\n",
       "                        Series Data\n",
       "uroot                   Unit Root Tests for Seasonal Time Series\n",
       "utf8                    Unicode Text Processing\n",
       "utils                   The R Utils Package\n",
       "uuid                    Tools for generating and handling of UUIDs\n",
       "viridisLite             Default Color Maps from 'matplotlib' (Lite\n",
       "                        Version)\n",
       "whisker                 {{mustache}} for R, logicless templating\n",
       "withr                   Run Code 'With' Temporarily Modified Global\n",
       "                        State\n",
       "xfun                    Miscellaneous Functions by 'Yihui Xie'\n",
       "xml2                    Parse XML\n",
       "xtable                  Export Tables to LaTeX or HTML\n",
       "xts                     eXtensible Time Series\n",
       "yaml                    Methods to Convert R Data to YAML and Back\n",
       "zoo                     S3 Infrastructure for Regular and Irregular\n",
       "                        Time Series (Z's Ordered Observations)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "library()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<ol class=list-inline>\n",
       "\t<li>1</li>\n",
       "\t<li>2</li>\n",
       "\t<li>5</li>\n",
       "\t<li>3</li>\n",
       "\t<li>6</li>\n",
       "\t<li>-2</li>\n",
       "\t<li>4</li>\n",
       "</ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 1\n",
       "\\item 2\n",
       "\\item 5\n",
       "\\item 3\n",
       "\\item 6\n",
       "\\item -2\n",
       "\\item 4\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 1\n",
       "2. 2\n",
       "3. 5\n",
       "4. 3\n",
       "5. 6\n",
       "6. -2\n",
       "7. 4\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "[1]  1  2  5  3  6 -2  4"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "a<-c(1, 2, 5, 3, 6, -2, 4)\n",
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<ol class=list-inline>\n",
       "\t<li>'one'</li>\n",
       "\t<li>'two'</li>\n",
       "\t<li>'three'</li>\n",
       "</ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 'one'\n",
       "\\item 'two'\n",
       "\\item 'three'\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 'one'\n",
       "2. 'two'\n",
       "3. 'three'\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "[1] \"one\"   \"two\"   \"three\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "b <- c(\"one\", \"two\", \"three\")\n",
    "b"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<ol class=list-inline>\n",
       "\t<li>TRUE</li>\n",
       "\t<li>TRUE</li>\n",
       "\t<li>TRUE</li>\n",
       "\t<li>FALSE</li>\n",
       "\t<li>TRUE</li>\n",
       "\t<li>FALSE</li>\n",
       "</ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item TRUE\n",
       "\\item TRUE\n",
       "\\item TRUE\n",
       "\\item FALSE\n",
       "\\item TRUE\n",
       "\\item FALSE\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. TRUE\n",
       "2. TRUE\n",
       "3. TRUE\n",
       "4. FALSE\n",
       "5. TRUE\n",
       "6. FALSE\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "[1]  TRUE  TRUE  TRUE FALSE  TRUE FALSE"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "c <- c(TRUE, TRUE, TRUE, FALSE, TRUE, FALSE)\n",
    "c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<ol class=list-inline>\n",
       "\t<li>'j'</li>\n",
       "\t<li>'h'</li>\n",
       "\t<li>'a'</li>\n",
       "\t<li>'c'</li>\n",
       "\t<li>'m'</li>\n",
       "</ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 'j'\n",
       "\\item 'h'\n",
       "\\item 'a'\n",
       "\\item 'c'\n",
       "\\item 'm'\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 'j'\n",
       "2. 'h'\n",
       "3. 'a'\n",
       "4. 'c'\n",
       "5. 'm'\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "[1] \"j\" \"h\" \"a\" \"c\" \"m\""
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    " a <- c(\"k\", \"j\", \"h\", \"a\", \"c\", \"m\")\n",
    "a[2:6]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<tbody>\n",
       "\t<tr><td>1 </td><td> 6</td><td>11</td><td>16</td></tr>\n",
       "\t<tr><td>2 </td><td> 7</td><td>12</td><td>17</td></tr>\n",
       "\t<tr><td>3 </td><td> 8</td><td>13</td><td>18</td></tr>\n",
       "\t<tr><td>4 </td><td> 9</td><td>14</td><td>19</td></tr>\n",
       "\t<tr><td>5 </td><td>10</td><td>15</td><td>20</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{llll}\n",
       "\t 1  &  6 & 11 & 16\\\\\n",
       "\t 2  &  7 & 12 & 17\\\\\n",
       "\t 3  &  8 & 13 & 18\\\\\n",
       "\t 4  &  9 & 14 & 19\\\\\n",
       "\t 5  & 10 & 15 & 20\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| 1  |  6 | 11 | 16 | \n",
       "| 2  |  7 | 12 | 17 | \n",
       "| 3  |  8 | 13 | 18 | \n",
       "| 4  |  9 | 14 | 19 | \n",
       "| 5  | 10 | 15 | 20 | \n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "     [,1] [,2] [,3] [,4]\n",
       "[1,] 1     6   11   16  \n",
       "[2,] 2     7   12   17  \n",
       "[3,] 3     8   13   18  \n",
       "[4,] 4     9   14   19  \n",
       "[5,] 5    10   15   20  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "y <- matrix(1:20, nrow=5, ncol=4)\n",
    "y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>C1</th><th scope=col>C2</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>R1</th><td> 1</td><td>26</td></tr>\n",
       "\t<tr><th scope=row>R2</th><td>24</td><td>68</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ll}\n",
       "  & C1 & C2\\\\\n",
       "\\hline\n",
       "\tR1 &  1 & 26\\\\\n",
       "\tR2 & 24 & 68\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | C1 | C2 | \n",
       "|---|---|\n",
       "| R1 |  1 | 26 | \n",
       "| R2 | 24 | 68 | \n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "   C1 C2\n",
       "R1  1 26\n",
       "R2 24 68"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "cells <- c(1,26,24,68)\n",
    "rnames <- c(\"R1\", \"R2\")\n",
    "cnames <- c(\"C1\", \"C2\")\n",
    "mymatrix <- matrix(cells, nrow=2, ncol=2, byrow=TRUE,\n",
    "dimnames=list(rnames, cnames))\n",
    "mymatrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th></th><th scope=col>C1</th><th scope=col>C2</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><th scope=row>R1</th><td> 1</td><td>24</td></tr>\n",
       "\t<tr><th scope=row>R2</th><td>26</td><td>68</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|ll}\n",
       "  & C1 & C2\\\\\n",
       "\\hline\n",
       "\tR1 &  1 & 24\\\\\n",
       "\tR2 & 26 & 68\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| <!--/--> | C1 | C2 | \n",
       "|---|---|\n",
       "| R1 |  1 | 24 | \n",
       "| R2 | 26 | 68 | \n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "   C1 C2\n",
       "R1  1 24\n",
       "R2 26 68"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "mymatrix <- matrix(cells, nrow=2, ncol=2, byrow=FALSE,\n",
    "dimnames=list(rnames, cnames))\n",
    "mymatrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<tbody>\n",
       "\t<tr><td>1 </td><td>3 </td><td>5 </td><td>7 </td><td> 9</td></tr>\n",
       "\t<tr><td>2 </td><td>4 </td><td>6 </td><td>8 </td><td>10</td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{lllll}\n",
       "\t 1  & 3  & 5  & 7  &  9\\\\\n",
       "\t 2  & 4  & 6  & 8  & 10\\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "| 1  | 3  | 5  | 7  |  9 | \n",
       "| 2  | 4  | 6  | 8  | 10 | \n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "     [,1] [,2] [,3] [,4] [,5]\n",
       "[1,] 1    3    5    7     9  \n",
       "[2,] 2    4    6    8    10  "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "x <- matrix(1:10, nrow=2)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<ol class=list-inline>\n",
       "\t<li>1</li>\n",
       "\t<li>2</li>\n",
       "\t<li>3</li>\n",
       "\t<li>4</li>\n",
       "\t<li>5</li>\n",
       "\t<li>6</li>\n",
       "\t<li>7</li>\n",
       "\t<li>8</li>\n",
       "\t<li>9</li>\n",
       "\t<li>10</li>\n",
       "\t<li>11</li>\n",
       "\t<li>12</li>\n",
       "\t<li>13</li>\n",
       "\t<li>14</li>\n",
       "\t<li>15</li>\n",
       "\t<li>16</li>\n",
       "\t<li>17</li>\n",
       "\t<li>18</li>\n",
       "\t<li>19</li>\n",
       "\t<li>20</li>\n",
       "\t<li>21</li>\n",
       "\t<li>22</li>\n",
       "\t<li>23</li>\n",
       "\t<li>24</li>\n",
       "</ol>\n"
      ],
      "text/latex": [
       "\\begin{enumerate*}\n",
       "\\item 1\n",
       "\\item 2\n",
       "\\item 3\n",
       "\\item 4\n",
       "\\item 5\n",
       "\\item 6\n",
       "\\item 7\n",
       "\\item 8\n",
       "\\item 9\n",
       "\\item 10\n",
       "\\item 11\n",
       "\\item 12\n",
       "\\item 13\n",
       "\\item 14\n",
       "\\item 15\n",
       "\\item 16\n",
       "\\item 17\n",
       "\\item 18\n",
       "\\item 19\n",
       "\\item 20\n",
       "\\item 21\n",
       "\\item 22\n",
       "\\item 23\n",
       "\\item 24\n",
       "\\end{enumerate*}\n"
      ],
      "text/markdown": [
       "1. 1\n",
       "2. 2\n",
       "3. 3\n",
       "4. 4\n",
       "5. 5\n",
       "6. 6\n",
       "7. 7\n",
       "8. 8\n",
       "9. 9\n",
       "10. 10\n",
       "11. 11\n",
       "12. 12\n",
       "13. 13\n",
       "14. 14\n",
       "15. 15\n",
       "16. 16\n",
       "17. 17\n",
       "18. 18\n",
       "19. 19\n",
       "20. 20\n",
       "21. 21\n",
       "22. 22\n",
       "23. 23\n",
       "24. 24\n",
       "\n",
       "\n"
      ],
      "text/plain": [
       ", , C1\n",
       "\n",
       "   B1 B2 B3\n",
       "A1  1  3  5\n",
       "A2  2  4  6\n",
       "\n",
       ", , C2\n",
       "\n",
       "   B1 B2 B3\n",
       "A1  7  9 11\n",
       "A2  8 10 12\n",
       "\n",
       ", , C3\n",
       "\n",
       "   B1 B2 B3\n",
       "A1 13 15 17\n",
       "A2 14 16 18\n",
       "\n",
       ", , C4\n",
       "\n",
       "   B1 B2 B3\n",
       "A1 19 21 23\n",
       "A2 20 22 24\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dim1 <- c(\"A1\", \"A2\")\n",
    "dim2 <- c(\"B1\", \"B2\", \"B3\")\n",
    "dim3 <- c(\"C1\", \"C2\", \"C3\", \"C4\")\n",
    "z <- array(1:24, c(2, 3, 4), dimnames=list(dim1, dim2, dim3))\n",
    "z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "15"
      ],
      "text/latex": [
       "15"
      ],
      "text/markdown": [
       "15"
      ],
      "text/plain": [
       "[1] 15"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "z[1,2,3]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table>\n",
       "<thead><tr><th scope=col>patientID</th><th scope=col>age</th><th scope=col>diabetes</th><th scope=col>status</th></tr></thead>\n",
       "<tbody>\n",
       "\t<tr><td>1        </td><td>25       </td><td>Type1    </td><td>Poor     </td></tr>\n",
       "\t<tr><td>2        </td><td>34       </td><td>Type2    </td><td>Improved </td></tr>\n",
       "\t<tr><td>3        </td><td>28       </td><td>Type1    </td><td>Excellent</td></tr>\n",
       "\t<tr><td>4        </td><td>52       </td><td>Type1    </td><td>Poor     </td></tr>\n",
       "</tbody>\n",
       "</table>\n"
      ],
      "text/latex": [
       "\\begin{tabular}{r|llll}\n",
       " patientID & age & diabetes & status\\\\\n",
       "\\hline\n",
       "\t 1         & 25        & Type1     & Poor     \\\\\n",
       "\t 2         & 34        & Type2     & Improved \\\\\n",
       "\t 3         & 28        & Type1     & Excellent\\\\\n",
       "\t 4         & 52        & Type1     & Poor     \\\\\n",
       "\\end{tabular}\n"
      ],
      "text/markdown": [
       "\n",
       "patientID | age | diabetes | status | \n",
       "|---|---|---|---|\n",
       "| 1         | 25        | Type1     | Poor      | \n",
       "| 2         | 34        | Type2     | Improved  | \n",
       "| 3         | 28        | Type1     | Excellent | \n",
       "| 4         | 52        | Type1     | Poor      | \n",
       "\n",
       "\n"
      ],
      "text/plain": [
       "  patientID age diabetes status   \n",
       "1 1         25  Type1    Poor     \n",
       "2 2         34  Type2    Improved \n",
       "3 3         28  Type1    Excellent\n",
       "4 4         52  Type1    Poor     "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "patientID <- c(1, 2, 3, 4)\n",
    "age <- c(25, 34, 28, 52)\n",
    "diabetes <- c(\"Type1\", \"Type2\", \"Type1\", \"Type1\")\n",
    "status <- c(\"Poor\", \"Improved\", \"Excellent\", \"Poor\")\n",
    "patientdata <- data.frame(patientID, age, diabetes, status)\n",
    "patientdata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "       \n",
       "        Excellent Improved Poor\n",
       "  Type1         1        0    2\n",
       "  Type2         0        1    0"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "table(patientdata$diabetes, patientdata$status)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "'data.frame':\t4 obs. of  4 variables:\n",
      " $ patientID: num  1 2 3 4\n",
      " $ age      : num  25 34 28 52\n",
      " $ diabetes : Factor w/ 2 levels \"Type1\",\"Type2\": 1 2 1 1\n",
      " $ status   : Ord.factor w/ 3 levels \"Excellent\"<\"Improved\"<..: 3 2 1 3\n"
     ]
    }
   ],
   "source": [
    "patientID <- c(1, 2, 3, 4)\n",
    "age <- c(25, 34, 28, 52)\n",
    "diabetes <- c(\"Type1\", \"Type2\", \"Type1\", \"Type1\")\n",
    "status <- c(\"Poor\", \"Improved\", \"Excellent\", \"Poor\")\n",
    "diabetes <- factor(diabetes)\n",
    "status <- factor(status, order=TRUE)\n",
    "patientdata <- data.frame(patientID, age, diabetes, status)\n",
    "str(patientdata)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "   patientID         age         diabetes       status \n",
       " Min.   :1.00   Min.   :25.00   Type1:3   Excellent:1  \n",
       " 1st Qu.:1.75   1st Qu.:27.25   Type2:1   Improved :1  \n",
       " Median :2.50   Median :31.00             Poor     :2  \n",
       " Mean   :2.50   Mean   :34.75                          \n",
       " 3rd Qu.:3.25   3rd Qu.:38.50                          \n",
       " Max.   :4.00   Max.   :52.00                          "
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "summary(patientdata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "ERROR while rich displaying an object: Error in FUN(X[[i]], ...): 不能用零长度变数名\n",
      "\n",
      "Traceback:\n",
      "1. FUN(X[[i]], ...)\n",
      "2. tryCatch(withCallingHandlers({\n",
      " .     rpr <- mime2repr[[mime]](obj)\n",
      " .     if (is.null(rpr)) \n",
      " .         return(NULL)\n",
      " .     prepare_content(is.raw(rpr), rpr)\n",
      " . }, error = error_handler), error = outer_handler)\n",
      "3. tryCatchList(expr, classes, parentenv, handlers)\n",
      "4. tryCatchOne(expr, names, parentenv, handlers[[1L]])\n",
      "5. doTryCatch(return(expr), name, parentenv, handler)\n",
      "6. withCallingHandlers({\n",
      " .     rpr <- mime2repr[[mime]](obj)\n",
      " .     if (is.null(rpr)) \n",
      " .         return(NULL)\n",
      " .     prepare_content(is.raw(rpr), rpr)\n",
      " . }, error = error_handler)\n",
      "7. mime2repr[[mime]](obj)\n",
      "8. repr_html.list(obj)\n",
      "9. repr_list_generic(obj, \"html\", \"\\t<li>%s</li>\\n\", \"\\t<dt>$%s</dt>\\n\\t\\t<dd>%s</dd>\\n\", \n",
      " .     \"<strong>$%s</strong> = %s\", \"<ol>\\n%s</ol>\\n\", \"<dl>\\n%s</dl>\\n\", \n",
      " .     numeric_item = \"\\t<dt>[[%s]]</dt>\\n\\t\\t<dd>%s</dd>\\n\", escape_fun = html_escape)\n",
      "10. sapply(nms, as.name, USE.NAMES = FALSE)\n",
      "11. lapply(X = X, FUN = FUN, ...)\n",
      "12. FUN(X[[i]], ...)\n",
      "ERROR while rich displaying an object: Error in FUN(X[[i]], ...): 不能用零长度变数名\n",
      "\n",
      "Traceback:\n",
      "1. FUN(X[[i]], ...)\n",
      "2. tryCatch(withCallingHandlers({\n",
      " .     rpr <- mime2repr[[mime]](obj)\n",
      " .     if (is.null(rpr)) \n",
      " .         return(NULL)\n",
      " .     prepare_content(is.raw(rpr), rpr)\n",
      " . }, error = error_handler), error = outer_handler)\n",
      "3. tryCatchList(expr, classes, parentenv, handlers)\n",
      "4. tryCatchOne(expr, names, parentenv, handlers[[1L]])\n",
      "5. doTryCatch(return(expr), name, parentenv, handler)\n",
      "6. withCallingHandlers({\n",
      " .     rpr <- mime2repr[[mime]](obj)\n",
      " .     if (is.null(rpr)) \n",
      " .         return(NULL)\n",
      " .     prepare_content(is.raw(rpr), rpr)\n",
      " . }, error = error_handler)\n",
      "7. mime2repr[[mime]](obj)\n",
      "8. repr_markdown.list(obj)\n",
      "9. repr_list_generic(obj, \"markdown\", \"%s. %s\\n\", \"$%s\\n:   %s\\n\", \n",
      " .     \"**$%s** = %s\", \"%s\\n\\n\", numeric_item = \"[[%s]]\\n:   %s\\n\", \n",
      " .     item_uses_numbers = TRUE, escape_fun = html_escape)\n",
      "10. sapply(nms, as.name, USE.NAMES = FALSE)\n",
      "11. lapply(X = X, FUN = FUN, ...)\n",
      "12. FUN(X[[i]], ...)\n",
      "ERROR while rich displaying an object: Error in FUN(X[[i]], ...): 不能用零长度变数名\n",
      "\n",
      "Traceback:\n",
      "1. FUN(X[[i]], ...)\n",
      "2. tryCatch(withCallingHandlers({\n",
      " .     rpr <- mime2repr[[mime]](obj)\n",
      " .     if (is.null(rpr)) \n",
      " .         return(NULL)\n",
      " .     prepare_content(is.raw(rpr), rpr)\n",
      " . }, error = error_handler), error = outer_handler)\n",
      "3. tryCatchList(expr, classes, parentenv, handlers)\n",
      "4. tryCatchOne(expr, names, parentenv, handlers[[1L]])\n",
      "5. doTryCatch(return(expr), name, parentenv, handler)\n",
      "6. withCallingHandlers({\n",
      " .     rpr <- mime2repr[[mime]](obj)\n",
      " .     if (is.null(rpr)) \n",
      " .         return(NULL)\n",
      " .     prepare_content(is.raw(rpr), rpr)\n",
      " . }, error = error_handler)\n",
      "7. mime2repr[[mime]](obj)\n",
      "8. repr_latex.list(obj)\n",
      "9. repr_list_generic(obj, \"latex\", \"\\\\item %s\\n\", \"\\\\item[\\\\$%s] %s\\n\", \n",
      " .     \"\\\\textbf{\\\\$%s} = %s\", enum_wrap = \"\\\\begin{enumerate}\\n%s\\\\end{enumerate}\\n\", \n",
      " .     named_wrap = \"\\\\begin{description}\\n%s\\\\end{description}\\n\", \n",
      " .     numeric_item = \"\\\\item[{[[%s]]}] %s\\n\", escape_fun = latex_escape)\n",
      "10. sapply(nms, as.name, USE.NAMES = FALSE)\n",
      "11. lapply(X = X, FUN = FUN, ...)\n",
      "12. FUN(X[[i]], ...)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "$title\n",
       "[1] \"My First List\"\n",
       "\n",
       "$ages\n",
       "[1] 25 26 18 39\n",
       "\n",
       "[[3]]\n",
       "     [,1] [,2]\n",
       "[1,]    1    6\n",
       "[2,]    2    7\n",
       "[3,]    3    8\n",
       "[4,]    4    9\n",
       "[5,]    5   10\n",
       "\n",
       "[[4]]\n",
       "[1] \"one\"   \"two\"   \"three\"\n"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "g <- \"My First List\"\n",
    "h <- c(25, 26, 18, 39)\n",
    "j <- matrix(1:10, nrow=5)\n",
    "k <- c(\"one\", \"two\", \"three\")\n",
    "mylist <- list(title=g, ages=h, j, k)\n",
    "mylist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "ename": "ERROR",
     "evalue": "Error in edit(mydata): 'edit()' not yet supported in the Jupyter R kernel\n",
     "execution_count": 21,
     "output_type": "error",
     "traceback": [
      "Error in edit(mydata): 'edit()' not yet supported in the Jupyter R kernel\nTraceback:\n",
      "1. edit(mydata)",
      "2. stop(sQuote(\"edit()\"), \" not yet supported in the Jupyter R kernel\")"
     ]
    }
   ],
   "source": [
    "mydata <- data.frame(age=numeric(0),\n",
    "gender=character(0), weight=numeric(0))\n",
    "mydata <- edit(mydata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "R [conda env:R3.4]",
   "language": "R",
   "name": "conda-env-R3.4-r"
  },
  "language_info": {
   "codemirror_mode": "r",
   "file_extension": ".r",
   "mimetype": "text/x-r-source",
   "name": "R",
   "pygments_lexer": "r",
   "version": "3.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
